package main

func main() {

	//strsArray := []string{"a", "b", "c"}
	//str := "sssssss"

	//测试用例
	nums := []int{2, 7, 11, 15}
	target := 9

	//打印测试用例返回结果
	resp := twoSum(nums, target)
	for _, v := range resp {
		println(v)
	}
	//println(resp)

}

func twoSum(nums []int, target int) []int {
	hashTable := map[int]int{}
	for i, x := range nums {
		if numKey, exist := hashTable[target-x]; exist {
			return []int{i, numKey}
		}
		hashTable[x] = i //向hashtable的数组下标的值插入数组下标对应的键
	}
	return nil
}
